<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<title>授权一览</title>
<head th:replace="system/inc/incHead :: incHead"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content no-padding">
    <form method="post" action="/google/auth.htm" enctype="multipart/form-data" class="pageForm required-validate"
          onsubmit="return iframeCallback(this, passwordChangeCallback)">
        <input type="hidden" id="cmd5" name="cmd5" value="">
        <input type="hidden" id="uid" name="uid" value="">
        <input type="hidden" id="randomData" name="randomData" value="">
        <input type="hidden" id="generateSecretKey" name="generateSecretKey" value="${generateSecretKey}">
        <div class="ibox no-margins no-padding no-borders">
            <div class="ibox-title p-xs ljFixBoxTitle" style="top:0px">
                <button class="btn btn-white btn-bitbucket btn-sm pull-left btnPageRefresh" type="button"><i class="fa fa-refresh">页面刷新</i></button>
                <div class="btn btn-sm btn-primary pull-right" id="btnEditSubmit"><i class="fa fa-paste">保存</i></div>
            </div>
            <div style="height:40px;"></div>
            <div class="ibox-content">
                <div class="row">
                    <div class="form-group col-md-12">
                        <label>谷歌验证码密钥(<b class="text-danger">*</b>):</label>
                        <input name="keyCode" type="text" class="form-control required" maxlength="32" value="${generateSecretKey}" readonly>
                        <label>二维码链接地址(<b class="text-danger">*</b>):</label>
                        <input type="text" class="form-control required" th:value="${getQRBarcodeURL}" readonly>
                        <div id="qrcode" style="text-align: left;" class="m-t m-l"></div>
                    </div>
                </div>
                <div class="row">
                    <div th:if="${isFirstBind=='0'}" class="form-group col-md-12">
                        <label>旧授权验证码(<b class="text-danger">*</b>):</label>
                        <input name="oldPass" type="text" placeholder="" class="form-control input-sm required" maxlength="32">
                    </div>
                    <div class="form-group col-md-12">
                        <label>新授权验证码(<b class="text-danger">*</b>):</label>
                        <input name="newPass" type="text" placeholder="" class="form-control input-sm required" maxlength="50">
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<head th:replace="system/inc/incBottom :: incBottom"></head>
<script src="/static/papper/js/jquery.qrcode.min.js"></script>
<script type="text/javascript" th:inline="javascript">
    /*<![CDATA[*/
    jQuery(function ($) {
        jQuery('#qrcode').qrcode({
            render: "canvas",
            width: 200,
            height: 200,
            text: '[[${getQRBarcodeURL}]]'
        });

        $(".chosen-select").chosen();
        $("#btnEditSubmit").on("click", function () {
            var values = {};
            modifyVerf(values);
            $("#cmd5").val(values.cmd5);
            $("#uid").val(values.uid);
            $("#randomData").val(values.randomData);
            $(this).closest("form").submit();
        });
    });

    function passwordChangeCallback(json) {
        if (json.statusCode == '300') {
            swal({
                title: "提交失败",
                text: json.message,
                type: "error"
            });

        } else if (json.statusCode == '301') {
            swal({
                title: "提交无权限",
                text: json.message,
                type: "warning"
            });

        } else if (json.statusCode == '200') {
            swal({
                    title: "授权修改",
                    text: "授权修改成功",
                    type: "success"
                },
                function (isConfirm) {
                    window.location.reload();
                });
        }
    }

    /*]]>*/
</script>
</body>
</html>
